﻿namespace Sidvall.AuthorizationManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class AuthorizationScopeResourceItemClaim : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim
    {
        #region Public Members

        #region AuthorizationScopeResourceItemClaimId

        private System.Nullable<long> _AuthorizationScopeResourceItemClaimId;
        partial void OnBeforeAuthorizationScopeResourceItemClaimIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterAuthorizationScopeResourceItemClaimIdPropertyChanged();
        public System.Nullable<long> AuthorizationScopeResourceItemClaimId
        { 
            get
            {
                return _AuthorizationScopeResourceItemClaimId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeResourceItemClaimId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _AuthorizationScopeResourceItemClaimId);
                    OnBeforeAuthorizationScopeResourceItemClaimIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeResourceItemClaimId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeResourceItemClaimIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceItemId

        private long _AuthorizationScopeResourceItemId;
        partial void OnBeforeAuthorizationScopeResourceItemIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterAuthorizationScopeResourceItemIdPropertyChanged();
        public long AuthorizationScopeResourceItemId
        { 
            get
            {
                return _AuthorizationScopeResourceItemId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeResourceItemId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _AuthorizationScopeResourceItemId);
                    OnBeforeAuthorizationScopeResourceItemIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeResourceItemId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeResourceItemIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region ClaimType

        private string _ClaimType;
        partial void OnBeforeClaimTypePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterClaimTypePropertyChanged();
        public string ClaimType
        { 
            get
            {
                return _ClaimType;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _ClaimType = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _ClaimType);
                    OnBeforeClaimTypePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("ClaimType", eventData.Value, true, true);
                        OnAfterClaimTypePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region ComparisonOperator

        private global::Sidvall.Data.ComparisonOperator _ComparisonOperator;
        partial void OnBeforeComparisonOperatorPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnAfterComparisonOperatorPropertyChanged();
        public global::Sidvall.Data.ComparisonOperator ComparisonOperator
        { 
            get
            {
                return _ComparisonOperator;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _ComparisonOperator = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator>(value, _ComparisonOperator);
                    OnBeforeComparisonOperatorPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("ComparisonOperator", eventData.Value, true, true);
                        OnAfterComparisonOperatorPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IsEnabled = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                    OnBeforeIsEnabledPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IsEnabled", eventData.Value, true, true);
                        OnAfterIsEnabledPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region Value

        private string _Value;
        partial void OnBeforeValuePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterValuePropertyChanged();
        public string Value
        { 
            get
            {
                return _Value;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Value = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Value);
                    OnBeforeValuePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Value", eventData.Value, true, true);
                        OnAfterValuePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        
        public AuthorizationScopeResourceItem AuthorizationScopeResourceItem { get; set; }
        #region LoadAuthorizationScopeResourceItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItem> LoadAuthorizationScopeResourceItemAsync()
        {
            return await LoadAuthorizationScopeResourceItemAsync(false, true, null, null, null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItem> LoadAuthorizationScopeResourceItemAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.LoadAuthorizationScopeResourceItemAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters).ConfigureAwait(false);

            return this.AuthorizationScopeResourceItem;
        }
        public AuthorizationScopeResourceItem LoadAuthorizationScopeResourceItem(AuthorizationScopeResourceItem item)
        {
            LoadInstanceField("AuthorizationScopeResourceItem", item, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public AuthorizationScopeResourceItemClaim Copy()
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Copy(this);
        }
        public AuthorizationScopeResourceItemClaim Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim item)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Import(this, item);
        }
        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Import(this, item, settings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, mode).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, settings).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceItemClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeResourceItemClaimManager.SaveItemAsync(this, settings, strategyContext, objectParameters).ConfigureAwait(false);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Initialize(this, settings);
        }

        #endregion

        #region IAuthorizationScopeResourceItemClaim Members

        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItemClaimId
        {
            get
            {
                return this._AuthorizationScopeResourceItemClaimId;
            }
            set
            {
                this._AuthorizationScopeResourceItemClaimId = value;
            }
        }
        long global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItemId
        {
            get
            {
                return this._AuthorizationScopeResourceItemId;
            }
            set
            {
                this._AuthorizationScopeResourceItemId = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.ClaimType
        {
            get
            {
                return this._ClaimType;
            }
            set
            {
                this._ClaimType = value;
            }
        }
        global::Sidvall.Data.ComparisonOperator global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.ComparisonOperator
        {
            get
            {
                return this._ComparisonOperator;
            }
            set
            {
                this._ComparisonOperator = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                this._Value = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItem global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim.AuthorizationScopeResourceItem
        {
            get
            {
                return this.AuthorizationScopeResourceItem;
            }
            set
            {
                this.AuthorizationScopeResourceItem = (AuthorizationScopeResourceItem)value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScopeResourceItemClaim()
        {
        }
        public AuthorizationScopeResourceItemClaim(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public AuthorizationScopeResourceItemClaim(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeResourceItemClaimManager.Initialize(this);
        }

        #endregion
    }
}